<template>
	<view class="container">
		<view class="form_unit">
			<view class="form_label">可提现金额</view>
			<input class="inputtext" type="text" :value="balance" disabled="true"/>
		</view>
		<view class="form_unit">
			<view class="form_label">申请提现金额</view>
			<input class="inputtext" type="number" min="10" :value="price" data-name="price" placeholder="请输入申请提现金额" @input="input_"/>
		</view>
		<view class="form_unit">
			<view class="form_label">银行卡号</view>
			<input class="inputtext" type="text" :value="bank_no" data-name="bank_no" placeholder="请输入银行卡号" @input="input_"/>
		</view>
		<view class="form_unit">
			<view class="form_label">银行卡开户行</view>
			<input class="inputtext" type="text" :value="bank_name" data-name="bank_name" placeholder="请输入银行卡名称" @input="input_"/>
		</view>
		<view class="form_unit">
			<view class="form_label">收款人姓名</view>
			<input class="inputtext" type="text" :value="withdraw_name" data-name="withdraw_name" placeholder="请输入收款人姓名" @input="input_"/>
		</view>
		<view class="detail" v-on:click="detail">查看提现明细</view>
		<view class="remark">请注意：提现会扣除6%手续费</view>
		<view class="button" v-on:click="add_submit">提交申请</view>
	</view>
</template>
<style>
	.container{width:96%;margin:10upx 2%;}
	radio{font-size: 28upx;padding-left:30upx;}
	.form_unit{width: 90%;margin:10upx 5%;border-bottom: 1px solid #f1f1f1;display: flex;justify-content: space-between;align-items: center;height: 80upx;}
	.form_label{width:30%;font-size: 28upx;color: #282828;text-align: right;padding-right:20upx;}
	.inputtext{font-size: 32upx;text-align: left;width: 65%;color: #333333;padding-left:3%;border-bottom: 1px solid #F1F1F1;}
	.button{width:90%;margin:20upx 5%;font-size: 30upx;height: 80upx;position: fixed;bottom:0;left:0;
			border-radius: 50upx;background-image: linear-gradient(#43eac9, #24c3a4);color: #FFFFFF;text-align: center;line-height: 80upx;}
	.detail {
		text-align: center;
		font-size: 20rpx;
		margin-top: 30px;
		color: blue;
	}
	.remark {
		color: rgba(90, 90, 90, 0.44);
		font-size: 30rpx;
		text-align: center;
		margin-top: 5%;
	}
</style>
<script>
	export default {
		data() {
			return {
				type :1,
				balance:'',
				price:'',
				height:'',
				bank_name:'',
				bank_no:'',
				withdraw_name:'',
				id:0,
				default_status:false,
				url: getApp().globalData.url,
				static:getApp().globalData.static
			}
		},
		onLoad(e) {
			var res = uni.getSystemInfoSync();
			this.height = res.windowWidth*0.96*0.5+"px";
			if(e.id!=undefined)
			{
				this.id = e.id;
				this.type = e.type;
			}
		},
		onShow()
		{
			// if(this.id!=0)
			// {
				this.initialize();
			// }
		},
		methods: {
			initialize:function()
			{
				var member_id = uni.getStorageSync("member_id");
				var that = this;
				// uni.request({
				// 	url: this.url+'/wechat_member_info',
				// 	data: {member_id:member_id},
				// 	header: {'Content-Type': 'application/json'},
				// 	success: (res) => {
				// 		console.log(res.data);
				// 		that.balance = res.data.result[0].balance;
				// 	}
				// });
				uni.request({
					url: this.url+'/wechat_withdraw_info',
					data: {member_id:member_id},
					header: {'Content-Type': 'application/json'},
					success: (res) => {
						console.log(res.data);
						that.balance = res.data.balance;
						that.bank_name = res.data.bank_name;
						that.bank_no = res.data.bank_no;
						that.withdraw_name = res.data.withdraw_name;
					}
				});
				// console.log(balance)
			},
			input_:function(e)
			{
				if(e.currentTarget.dataset.name=="price")
				{
					this.price = e.target.value;
				}
				if(e.currentTarget.dataset.name=="bank_name")
				{
					this.bank_name = e.target.value;
				}
				if(e.currentTarget.dataset.name=="bank_no")
				{
					this.bank_no = e.target.value;
				}
				if(e.currentTarget.dataset.name=="withdraw_name")
				{
					this.withdraw_name = e.target.value;
				}
			},
			add_submit:function()
			{
				var member_id = uni.getStorageSync("member_id");
				var that = this;
				uni.request({
					url: this.url+'/wechat_submit_withdraw_application',
					data: {member_id:member_id,amount:this.price,bank_no:that.bank_no,bank_name:that.bank_name,withdraw_name:that.withdraw_name},
					header: {'Content-Type': 'application/json'},
					success: (res) => {
						// console.log(res.data);
						if(res.data.status==1)
						{
							uni.showToast({
								title:"申请成功",
								duration:1500
							})
							setTimeout(function(){uni.redirectTo({url:'withdraw_title'})},1500)
						}
						else
						{
							uni.showModal({
								title:"操作提示",
								content:res.data.err_msg,
								showCancel:false})
						}
					}
				});
			},
			detail:function()
			{
				uni.redirectTo({url:'withdraw_title'});
			},
      IntInput(event) {
			  let that = this;
        var val =  event.detail.value.replace(/[^0-9]/g, '');
        that.$set(that.CustomerInfoValues, event.target.dataset.index, val);
      },
		}
	}
</script>
